<template>
	<view class="home_box">
		<view class="home_banner">
			<view class="banner">
				<swiper :autoplay="true" :interval="4000" :duration="1000" indicator-dots circular
					indicator-color="rgba(0, 0, 0, .3)" indicator-active-color="#fff" class="swiper-item_box">
					<!-- 	<swiper-item class="banner_image" @click="goSecretary">
						<image src="https://mysmallapp.oss-cn-shanghai.aliyuncs.com/aixz/img/homeBanner1.png"
							mode="widthFix"></image>
					</swiper-item> -->
					<swiper-item class="banner_image" @click="goAiWriting">
						<image src="https://mysmallapp.oss-cn-shanghai.aliyuncs.com/aixz/img/homeBanner3.png"
							style="width: 100%;" mode="widthFix"></image>
					</swiper-item>
					<swiper-item class="banner_image" @click="goTextToSpeech">
						<image src="https://iflytts.oss-cn-qingdao.aliyuncs.com/website/img/webway/1.png"
							style="width: 100%;" mode="widthFix"></image>
					</swiper-item>
					<swiper-item class="banner_image" @click="goCopywritingExtraction">
						<image src="https://mysmallapp.oss-cn-shanghai.aliyuncs.com/aixz/img/homeBanner4.png"
							style="width: 100%;" mode="widthFix"></image>
					</swiper-item>
				</swiper>
			</view>
		</view>
		<!-- 悬浮拖动按钮 -->
		<!-- <liu-drag-button @clickBtn="clickBtn" v-if="navback">按钮</liu-drag-button> -->
		<view class="home_tools">
			<!-- <view class="home_ts" @click="tabGq" v-if="navback">
				<image src="../../static/home/gq.png" mode="widthFix" style="width:100%;height: 100%;"></image>
			</view> -->
			<view class="tools_left" @click="goSmartSecretary">
				<text class="left_title">AI智能写作</text>
				<text class="left_text">文案智能创作</text>
				<image src="../../static/home/homeWriting.png" mode=""></image>
			</view>
			<view class="tools_right">
				<view class="right_top" @click="goAiWriting">
					<text class="right_title">AI伪原创</text>
					<text class="right_text">一键改写您的专属文章</text>
				</view>
				<view class="right_down">
					<view class="down_left" @click="goAitool">
						<text class="right_title">AI对话</text>
						<text class="right_text">开启智能AI对话</text>
					</view>
					<view class="down_right" @click="goTextSoundh">
						<text class="right_title">私人助理</text>
						<text class="right_text">专属私人助理</text>
					</view>
				</view>
			</view>
		</view>
		<view class="home_writing">
			<text>AI写作</text>
			<view style="width: 41rpx;height: 5rpx;background-color: #379AFF;"></view>
			<u-line color="#E2E2E2" />
		</view>
		<view class="home_otherTools">
			<u-grid :border="false" col="3">
				<u-grid-item v-for="(tiem, index) in otherTools" :key="index" @click="goOtherTools(tiem)">
					<u-icon :custom-style="{ padding: 20 + 'rpx' }" :name="tiem.image" :size="65">
					</u-icon>
					<text class="otherTools_title">{{ tiem.title }}</text>
				</u-grid-item>
			</u-grid>
		</view>
		<!-- <view style="width: 100%;height: 20rpx;background-color: #f4f4f4;"></view> -->
		<u-popup :show="statementShows" mode="center" @close="close" :closeable="false" :closeOnClickOverlay="false"
			round="14">
			<view class="statementboxs">
				<view class="statements">
					<image src="../../static/home/nosay.png" mode=""></image>
				</view>
				<view class="statemens">
					<image src="../../static/home/jyla.jpg" mode=""></image>
				</view>
				<view class="statementtexts">
					你的账号存在违规,请联系客服解封
					如以解封，请删除重进，有五分钟缓冲时间
				</view>
				<view class="surebtnstyles">
					<view class="surebtn" @click="closer">
						联系客服
					</view>
				</view>
			</view>
		</u-popup>

		<!-- #ifdef MP-WEIXIN -->
		<jade-mp-privacy initiative></jade-mp-privacy>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		vipType,
		isLogin
	} from '../../business/login.js'
	import {
		getInfo
	} from "@/business/systeminfo.js";
	import {
		grayControl,
		National
	} from '@/utils/grayControl.js'
	import store from '@/store/idnex.js'
	import {
		apiMixUrlApi,
	} from '@/api/assemb.js'
	export default {
		data() {
			return {
				navback: false,
				statementShow: false,
				statementShows: false,
				otherTools: [{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome1.png',
						title: '文章续写',
						url: '/pages_aiTools/continuation/continuation'
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome2.png',
						title: '文案提取',
						url: '/pages_aiTools/copywritingExtraction/copywritingExtraction'
						// url: '/pages_aiTools/studeplay/studeplay'
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome3.png',
						title: '电脑版',
						url: '/pages/copute/copute'
						// url: '/pages_aiTools/TVcom/TVcom',
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome4.png',
						title: '学生作文',
						url: '/pages_aiTools/student/student',
						// url: '/pages_aiTools/copywritingExtraction/copywritingExtraction'
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome5.png',
						title: '论文',
						url: '/pages_aiTools/paper/paper',
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome6.png',
						title: '教案计划',
						url: '/pages_aiTools/studeplay/studeplay'
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome7.png',
						title: '周报日报',
						url: '/pages_otherTools/natework/natework',
					},
				
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome8.png',
						title: '活动策划',
						url: '/pages_otherTools/activity/activity',
					},


					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome9.png',
						title: '工作总结',
						url: '/pages_otherTools/yearend/yearend'
					},
					{
						image: '/static/home/01.png',
						title: '提词器',
						url:'/pages_otherTools/prompter/prompter'
					},
									
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome13.png',
						title: '短视频文案',
						url: '/pages_aiTools/video/video',
					},
					
					
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome15.png',
						title: '新媒体写作',
						url: '/pages_aiTools/newtool/newtool',
					},
					
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome10.png',
						title: '去水印',
						url: '/pages_otherTools/audioJoiningVideos/audioJoiningVideos'
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome11.png',
						title: '影视解说',
						url: '/pages_aiTools/TVcom/TVcom',
					},
					{
						image: 'https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/aixz/newxzy/newhome14.png',
						title: '文字转语音',
						tab:0
					},
					
				]
			};
		},
		onLoad(options) {
			let that = this
			console.log('options=========>', options)
			let userid = ''
			if (!!options.userid) {
				userid = options.userid;
			}
			if (!!options.scene) {
				userid = options.scene;
			}
			if (userid) {
				uni.setStorageSync("inviterId", userid);
			}
			if (options.jumpParameter) {
				uni.setStorageSync("jumpParameter", options.jumpParameter);
			} else {
				uni.removeStorageSync('jumpParameter');
			}

			if (uni.getStorageSync('statement')) {
				that.statementShow = false;
			} else {
				that.statementShow = true;
			}
			//判断小程序隐私协议弹窗是否弹出


			// 获取ip
			// uni.request({
			// 	url: 'https://ip.tool.lu?format=json',
			// 	success: function(res) {
			// 		console.log('------------IP地址----------------:', res.data);
			// 		uni.request({
			// 			url: 'https://sslwxbd.peiyinapp.com/bizad/ad/dyad/monitor?df=shenhe&appid=' +
			// 				store.state.appid + '&oaid=1&ip=' + res.data,
			// 			data: {},
			// 			method: 'GET',
			// 			success: function(res) {}
			// 		});
			// 	}
			// });
		},
		onShow() {
			let that = this
			if (uni.getStorageSync('time')) {
				console.log('这里面额没有')
				if (uni.getStorageSync('time') < Date.parse(new Date())) {
					that.removieToken()
				}
			} else {
				console.log('这里有')
				that.removieToken()
			}

			if (isLogin()) {
				grayControl()
			}
			if (uni.getStorageSync('ban')) {
				that.statementShows = true;
			} else {
				that.statementShows = false;
			}
		},
		onShareAppMessage: function(res) {
			const that = this
			let userid = uni.getStorageSync('baseinfo').userid
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target, 'res.target')
			}
			return {
				title: 'AI写作神器，一键改写变原创。',
				path: "pages/home/home?userid=" + userid,
				imageUrl: "https://iflytts.oss-cn-qingdao.aliyuncs.com/wxapp/xze/6.png",
				success: function(res) {
					console.log(
						"--------------转发成功--------------------",
						res,
						userid
					);
				}
			}
		},
		onShareTimeline: function(res) {},
		methods: {
			//获取token
			removieToken() {
				//获取token的接口登陆之后调
				apiMixUrlApi('', 1106, "MixAuthToken").then(data => {
					console.log(data, '这个是获取token的接口')
					uni.setStorageSync('time', data.expires_time);
					let baseinfo = uni.getStorageSync('baseinfo');
					console.log(baseinfo, '这是本地的数据')
					baseinfo.token = data.access_token;
					console.log(baseinfo.token, 'token存了没有')
					uni.setStorageSync('baseinfo', baseinfo);
					console.log(Date.parse(new Date()))
				})
			},
			//判断本地有没有存判断token过期的时间戳没有的话调获取token的接口 有的话获取本地时间判断token有没有过期
			// if (uni.getStorageSync('time')) {
			// 	if (uni.getStorageSync('time') < Date.parse(new Date())) {
			// 		this.getToken()
			// 	}
			// } else {
			// 	this.getToken()
			// }
			// if (uni.getStorageSync('time')) {
			// 	if (uni.getStorageSync('time') < Date.parse(new Date())) {
			// 		this.getToken()
			// 	}
			// } else {
			// 	this.getToken()
			// }
			goAitool(){
				uni.navigateTo({
					url: '/pages/dialogue/dialogue'
				})
			},
			clickBtn() {
				if (uni.getStorageSync("jumpParameter")) {
					uni.navigateBackMiniProgram({
						extraData: {

						},
						success(res) {
							// 返回成功
						}
					})
				} else {
					uni.navigateToMiniProgram({
						appId: 'wx8cdc1076c022d6fe', // appid
						path: 'pages/avatar/avatar', // 首页路径
						envVersion: "release",
						success: res => {
							// 打开成功
							console.log("打开成功", res);
						},
						fail: err => {
							console.log(err);
						}
					})
				}
			},
			//点击跳转客服
			closer() {
				uni.navigateTo({
					url: '/pages/service/service'
				})
			},
			//点击确定关闭背景图
			close() { //往本地存一个值
				uni.setStorageSync("statement", true);
				this.statementShow = false;
			},
			toPay() {
				if (uni.getStorageSync('OS') !== 'ios') {
					uni.navigateTo({
						url: '/pages/paymentCenter/paymentCenter'
					});
				} else {
					if (getApp().globalData.iosPay == 0) {
						uni.showModal({
							title: '提示',
							content: '由于相关规范，IOS功能暂不可用',
							showCancel: false,
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						});
					} else if (getApp().globalData.iosPay == 1) {
						uni.navigateTo({
							url: '/pages/goods/goods'
						});
					}
				}
			},
			/*
			 *	@	跳转文案提取
			 */
			goCopywritingExtraction() {
				uni.navigateTo({
					url: '/pages_aiTools/copywritingExtraction/copywritingExtraction'
				});
			},
			/*
			 *	@	跳转去除水印
			 */
			goAudioJoiningVideos() {
				uni.navigateTo({
					url: '/pages_otherTools/audioJoiningVideos/audioJoiningVideos'
				});
			},
			/*
			 *	@	跳转文字转语音
			 */
			goTextToSpeech() {
				if (uni.getStorageSync("jumpParameter")) {
					uni.navigateBackMiniProgram({
						extraData: {

						},
						success(res) {
							// 返回成功
						}
					})
				} else {
					uni.navigateToMiniProgram({
						appId: 'wx9919428d9725e8ef', // appid
						path: 'pages/index/index', // 首页路径
						envVersion: "release",
						success: res => {
							// 打开成功
							console.log("打开成功", res);
						},
						fail: err => {
							console.log(err);
						}
					})
				}
			},
			goSecretary() {
				uni.navigateTo({
					// url: '/pages_aiTools/secretary/secretary'
					url: '/pages_aiTools/creation/creation'
				});
			},
			/*
			 *	@	跳转AI写作
			 */
			goAiWriting() {
				uni.navigateTo({
					url: '/pages_aiTools/aiWriting/aiWriting'
				});
			},
			goWatermark() {
				uni.navigateTo({
					url: '/pages_otherTools/audioJoiningVideos/audioJoiningVideos'
				});
			},
			goTextSoundh() {
				uni.navigateTo({
					url: '/pages/srzl/srzl'
				});
			},
			goSmartSecretary() {
				uni.navigateTo({
					url: '/pages_aiTools/creation/creation'
				});
			},
			/*
			 *	@
			 */
			goOtherTools(name) {
				if(name.tab == 0){
					console.log('1')
					this.goTextToSpeech()
				}else{
					uni.navigateTo({
						url: name.url
					});
				}
				
			}
		}
	};
</script>

<style lang="scss" scoped>
	/deep/.swiper-item_box {
		height: 257.85rpx;
	}
	/deep/.u-icon__img {
		width: 112rpx !important;
		height: 112rpx !important;
	}

	.statementboxs {
		width: 620rpx;
		// height: 572rpx;

		.statements {
			display: flex;
			justify-content: center;
			margin-top: 50rpx;

			image {
				width: 114rpx;
				height: 114rpx;
			}
		}

		.statemens {
			display: flex;
			justify-content: center;
			margin-top: 50rpx;

			image {
				width: 220rpx;
				height: 66rpx;
			}
		}

		.statementtexts {
			// margin-left: 300rpx;
			font-size: 26rpx;
			margin-top: 60rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			margin: 0 115rpx;
			margin-top: 58rpx;
			margin-bottom: 48rpx;
		}

		.surebtnstyles {
			display: flex;
			justify-content: center;

			.surebtn {
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 34rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				width: 440rpx;
				height: 117rpx;
				background-repeat: no-repeat;
				background-size: cover;
				background-image: url("https://mysmallapp.oss-cn-shanghai.aliyuncs.com/aixz/img/xzybg.png");
			}
		}
	}

	.statementbox {
		width: 620rpx;
		height: 572rpx;

		.statement {
			display: flex;
			justify-content: center;
			margin-top: 50rpx;

			image {
				width: 114rpx;
				height: 55rpx;
			}
		}

		.statementtext {
			font-size: 25rpx;
			margin-top: 60rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			margin: 0 70rpx;
			margin-top: 58rpx;
			margin-bottom: 48rpx;
		}

		.surebtnstyle {
			display: flex;
			justify-content: center;

			.surebtn {
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 34rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				width: 440rpx;
				height: 117rpx;
				background-repeat: no-repeat;
				background-size: cover;
				background-image: url("https://mysmallapp.oss-cn-shanghai.aliyuncs.com/aixz/img/xzybg.png");
			}
		}
	}

	.home_box {
		.home_banner {
			width: 100%;
			height: 353rpx;
			background-image: linear-gradient(to bottom, #6B9CFF, #72a2ff, #93b6ff, #fff);

			.banner {
				width: 706.52rpx;
				height: 257.85rpx;
				margin: auto;

				.banner_image {
					width: 100%;

					height: 257.85rpx !important image {
						width: 706.52rpx;
						height: 257.85rpx;
					}
				}
			}
		}

		.home_tools {
			display: flex;
			justify-content: space-between;
			padding: 0 24rpx 0 24rpx;
			margin-top: -60rpx;
			position: relative;

			.home_ts {
				width: 100rpx;
				height: 100rpx;
				position: absolute;
				bottom: -100rpx;
				left: 630rpx;
			}

			.tools_left {
				display: flex;
				flex-direction: column;
				justify-content: center;
				width: 225rpx;
				height: 286rpx;
				border-radius: 18rpx;
				background-color: #6799FF;

				.left_title {
					margin-left: 25rpx;
					font-size: 34rpx;
					color: #FFFFFF;
				}

				.left_text {
					margin-left: 25rpx;
					font-size: 22rpx;
					color: #DFEAFF;
				}

				image {
					margin-left: 40rpx;
					margin-top: 31rpx;
					width: 149rpx;
					height: 131rpx;
				}
			}

			.tools_right {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.right_top {
					display: flex;
					flex-direction: column;
					justify-content: center;
					width: 458rpx;
					height: 135rpx;
					background: #F0F5FF;
					border-radius: 12rpx;


				}

				.right_down {
					display: flex;
					justify-content: space-between;

					.down_left {
						display: flex;
						flex-direction: column;
						justify-content: center;
						width: 219rpx;
						height: 134rpx;
						background: #FFF1F1;
						border-radius: 12rpx;
					}

					.down_right {
						display: flex;
						flex-direction: column;
						justify-content: center;
						width: 219rpx;
						height: 134rpx;
						background: #F2F2FF;
						border-radius: 12rpx;
					}
				}
			}
		}

		.right_title {
			margin-left: 34rpx;
			font-size: 31rpx;
			font-family: PingFang SC;
			color: #333333;
		}

		.right_text {
			margin-left: 34rpx;
			font-size: 22rpx;
			font-family: PingFang SC;
			color: #4E4E4E;
		}

		.home_writing {
			width: 100%;
			height: 92rpx;
			line-height: 92rpx;
			font-size: 29rpx;
			color: #363636;
			padding: 0 42rpx;
			box-sizing: border-box;
		}

		.home_otherTools {
			margin-top: 14rpx;
			// padding: 6rpx 20rpx;
			// padding: 10rpx 20rpx;

			.otherTools_title {
				
				font-weight: 500;
				padding-bottom: 20rpx;
				font-size: 25rpx;
				font-family: PingFang SC;
				color: #333333;
				line-height: 26rpx;
			}
		}
	}
</style>